1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.FilterListModel; 26 27 private import gio.ListModelIF; 28 private import gio.ListModelT; 29 private import glib.ConstructionException; 30 private import gobject.ObjectG; 31 private import gtk.Filter; 32 private import gtk.c.functions; 33 public import gtk.c.types; 34 35 36 /** 37 * `GtkFilterListModel` is a list model that filters the elements of 38 * the underlying model according to a `GtkFilter`. 39 * 40 * It hides some elements from the other model according to 41 * criteria given by a `GtkFilter`. 42 * 43 * The model can be set up to do incremental searching, so that 44 * filtering long lists doesn't block the UI. See 45 * [method@Gtk.FilterListModel.set_incremental] for details. 46 */ 47 public class FilterListModel : ObjectG, ListModelIF 48 { 49 /** the main Gtk struct */ 50 protected GtkFilterListModel* gtkFilterListModel; 51 52 /** Get the main Gtk struct */ 53 public GtkFilterListModel* getFilterListModelStruct(bool transferOwnership = false) 54 { 55 if (transferOwnership) 56 ownedRef = false; 57 return gtkFilterListModel; 58 } 59 60 /** the main Gtk struct as a void* */ 61 protected override void* getStruct() 62 { 63 return cast(void*)gtkFilterListModel; 64 } 65 66 /** 67 * Sets our main struct and passes it to the parent class. 68 */ 69 public this (GtkFilterListModel* gtkFilterListModel, bool ownedRef = false) 70 { 71 this.gtkFilterListModel = gtkFilterListModel; 72 super(cast(GObject*)gtkFilterListModel, ownedRef); 73 } 74 75 // add the ListModel capabilities 76 mixin ListModelT!(GtkFilterListModel); 77 78 79 /** */ 80 public static GType getType() 81 { 82 return gtk_filter_list_model_get_type(); 83 } 84 85 /** 86 * Creates a new `GtkFilterListModel` that will filter @model using the given 87 * @filter. 88 * 89 * Params: 90 * model = the model to sort 91 * filter = filter 92 * 93 * Returns: a new `GtkFilterListModel` 94 * 95 * Throws: ConstructionException GTK+ fails to create the object. 96 */ 97 public this(ListModelIF model, Filter filter) 98 { 99 auto __p = gtk_filter_list_model_new((model is null) ? null : model.getListModelStruct(), (filter is null) ? null : filter.getFilterStruct()); 100 101 if(__p is null) 102 { 103 throw new ConstructionException("null returned by new"); 104 } 105 106 this(cast(GtkFilterListModel*) __p, true); 107 } 108 109 /** 110 * Gets the `GtkFilter` currently set on @self. 111 * 112 * Returns: The filter currently in use 113 */ 114 public Filter getFilter() 115 { 116 auto __p = gtk_filter_list_model_get_filter(gtkFilterListModel); 117 118 if(__p is null) 119 { 120 return null; 121 } 122 123 return ObjectG.getDObject!(Filter)(cast(GtkFilter*) __p); 124 } 125 126 /** 127 * Returns whether incremental filtering is enabled. 128 * 129 * See [method@Gtk.FilterListModel.set_incremental]. 130 * 131 * Returns: %TRUE if incremental filtering is enabled 132 */ 133 public bool getIncremental() 134 { 135 return gtk_filter_list_model_get_incremental(gtkFilterListModel) != 0; 136 } 137 138 /** 139 * Gets the model currently filtered or %NULL if none. 140 * 141 * Returns: The model that gets filtered 142 */ 143 public ListModelIF getModel() 144 { 145 auto __p = gtk_filter_list_model_get_model(gtkFilterListModel); 146 147 if(__p is null) 148 { 149 return null; 150 } 151 152 return ObjectG.getDObject!(ListModelIF)(cast(GListModel*) __p); 153 } 154 155 /** 156 * Returns the number of items that have not been filtered yet. 157 * 158 * You can use this value to check if @self is busy filtering by 159 * comparing the return value to 0 or you can compute the percentage 160 * of the filter remaining by dividing the return value by the total 161 * number of items in the underlying model: 162 * 163 * ```c 164 * pending = gtk_filter_list_model_get_pending (self); 165 * model = gtk_filter_list_model_get_model (self); 166 * percentage = pending / (double) g_list_model_get_n_items (model); 167 * ``` 168 * 169 * If no filter operation is ongoing - in particular when 170 * [property@Gtk.FilterListModel:incremental] is %FALSE - this 171 * function returns 0. 172 * 173 * Returns: The number of items not yet filtered 174 */ 175 public uint getPending() 176 { 177 return gtk_filter_list_model_get_pending(gtkFilterListModel); 178 } 179 180 /** 181 * Sets the filter used to filter items. 182 * 183 * Params: 184 * filter = filter to use 185 */ 186 public void setFilter(Filter filter) 187 { 188 gtk_filter_list_model_set_filter(gtkFilterListModel, (filter is null) ? null : filter.getFilterStruct()); 189 } 190 191 /** 192 * Sets the filter model to do an incremental sort. 193 * 194 * When incremental filtering is enabled, the `GtkFilterListModel` will not 195 * run filters immediately, but will instead queue an idle handler that 196 * incrementally filters the items and adds them to the list. This of course 197 * means that items are not instantly added to the list, but only appear 198 * incrementally. 199 * 200 * When your filter blocks the UI while filtering, you might consider 201 * turning this on. Depending on your model and filters, this may become 202 * interesting around 10,000 to 100,000 items. 203 * 204 * By default, incremental filtering is disabled. 205 * 206 * See [method@Gtk.FilterListModel.get_pending] for progress information 207 * about an ongoing incremental filtering operation. 208 * 209 * Params: 210 * incremental = %TRUE to enable incremental filtering 211 */ 212 public void setIncremental(bool incremental) 213 { 214 gtk_filter_list_model_set_incremental(gtkFilterListModel, incremental); 215 } 216 217 /** 218 * Sets the model to be filtered. 219 * 220 * Note that GTK makes no effort to ensure that @model conforms to 221 * the item type of @self. It assumes that the caller knows what they 222 * are doing and have set up an appropriate filter to ensure that item 223 * types match. 224 * 225 * Params: 226 * model = The model to be filtered 227 */ 228 public void setModel(ListModelIF model) 229 { 230 gtk_filter_list_model_set_model(gtkFilterListModel, (model is null) ? null : model.getListModelStruct()); 231 } 232 }